<?php
header("content-type:text/html;charset=utf8");
$usename=$_POST["usename"];
$password=$_POST["password"];
$con=mysqli_connect("localhost","root","root","test");
$sql="select * from user where usename='$usename'";
$res=mysqli_query($con,$sql);
$row=mysqli_fetch_assoc($res);
if($row){
    $sql="select * from user where usename='$usename' and password='$password'";
    $res=mysqli_query($con,$sql);
    $row=mysqli_fetch_assoc($res);
if($row){
    $arr=[
        "msg"=>"登录成功",
        "status"=>200
    ];
}else{
    $arr=[
        "msg"=>"登录失败",
        "status"=>4
    ]; 
}
}else{
    $arr=[
        "msg"=>"用户名不存在",
        "status"=>3
    ]; 
}
echo json_encode($arr);